home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 February
/
Macworld (1998-02).dmg
/
Inside Macworld
/
Alphamania 2 & Effector Sets
/
AlphaMania 2
/
Set FX.dir
/
00091_Script_Pointer Object
< prev
next >
Wrap
Text File
|
1997-12-19
|
3KB
|
96 lines
property pPointerSprite, pTextSprite, pTextField, pCurVal, pCallBackObj, pRefcon
property pRange, pMin, pMax, pSliderLeft, pSliderWidth, pActive
on new me, proplist
set pPointerSprite = getAProp(proplist,#thumbSprite)
set pTextSprite = getAProp(proplist,#textSprite)
set pTextField = getAProp(proplist,#textField)
set pMin = getAProp(proplist,#min)
set pMax = getAProp(proplist,#max)
set pCurVal = getAProp(proplist,#cur)
set pRange = pMax - pMin
set pActive = getAProp(proplist,#active)
set pSliderLeft = getAProp(proplist,#left)
set pSliderWidth = getAProp(proplist,#width)
set pActive = getAProp(proplist,#active)
set pCallBackObj = getAProp(proplist,#callback)
set pRefCon = getAProp(proplist,#ref)
setVal(me,pCurVal)
setEnabled(me,pActive)
return(me)
end
on Drag me
if not pActive then exit
repeat while the stillDown
put min(max(the mouseH,pSliderLeft),pSliderLeft+pSliderWidth) into h
set the locH of sprite pPointerSprite = h
updateStage
set loc = the locH of sprite pPointerSprite - pSliderLeft
set newVal = ((pRange*loc)/(pSliderWidth))+pMin
SetVal(me, newVal)
if objectP(pCallBackObj) then DoDrag(pCallBackObj, pRefcon, newVal)
end repeat
if objectP(pCallBackObj) then EndChange(pCallBackObj)
end
on CalcVal me, numerator, denom, otherDenom
set val = (otherDenom * numerator) / denom
return(val)
end
on TextOut me
if voidP(pCurVal) then put " " into field pTextField
else put string(integer(pCurVal)) into field pTextField
end
on keyBoardInputDown me, k
if not pActive then exit
if "-0123456789"&BACKSPACE contains k then
pass
else
dontpassevent
end if
end
on keyBoardInputUp me, k
if not pActive then exit
put (field pTextField) into v
if v = "-" then put -0 into v
else put value(v) into v
if v < pMin then put string(pMin) into field pTextField
else if v > pMax then put string(pMax) into field pTextField
set pCurVal = value(field pTextField)
changeNumber(pCallBackObj, pCurVal, pRefcon)
puppetSprite pPointerSprite, TRUE
set loc = CalcVal(me, pCurVal-pMin, pRange, pSliderWidth)
set the locH of sprite pPointerSprite = pSliderLeft + loc
if objectP(pCallBackObj) then DoDrag(pCallBackObj, pRefcon, pCurVal)
if objectP(pCallBackObj) then EndChange(pCallBackObj, pRefcon, pCurVal)
end
on SetVal me, newVal
puppetSprite pPointerSprite, TRUE
set pCurVal = newVal
if voidP(newVal) then put max(0,pMin) into newVal
TextOut(me)
set loc = CalcVal(me, newVal-pMin, pRange, pSliderWidth)
set the locH of sprite pPointerSprite = pSliderLeft + loc
--updateStage
end
on SetEnabled me, enabled
set pActive = enabled
enableInterfaceElement(pPointerSprite,enabled)
enableInterfaceElement(pTextSprite,enabled)
end
on Release me
-- release all puppets, constraints, etc.
puppetSprite pPointerSprite, FALSE
end